﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using blackhouse.BlackApart.Business.Reservations;

namespace blackhouse.BlackApart.Business.Calendar {
    public class CompositeCalendar : ICalendar {

        #region Fields

        private ICalendar[] calendars;

        #endregion

        #region Properties

        public DateTime FromDay { get; private set; }

        public DateTime ToDay { get; private set; }

        #endregion

        #region Constructors

        public CompositeCalendar(params ICalendar[] allCalendars) {
            this.calendars = allCalendars;
            if (this.calendars.Length > 0) {
                this.FromDay = this.calendars.Max(c => c.FromDay);
                this.ToDay = this.calendars.Min(c => c.ToDay);
            }
        }

        #endregion

        #region ICalendar Members

        public int GetDayState(DateTime day) {
            return calendars.Sum(c => c.GetDayState(day));
        }

        #endregion

    }
}
